package main

import "fmt"

/*
  抽象工厂模式
  抽象工厂模式有多个抽象产品类
  抽象工厂是针对一个产品族而言的.产品族就好像套餐.一个套餐包含了好几种食品，而每一种食品都是一种类型的食物。举个例子.
  一个套餐定义为食品和饮料.而有一家餐馆的食品包括牛肉和鱼肉，饮料包括牛奶和茶.这家餐馆不想单独出售某种食品和饮料，只卖套餐.
*/

type Food interface {
	Eat()
}

type Drink interface {
	Drink()
}

// 餐厅抽象工厂
type RestaurantFactory interface {
	CreateFood() Food
	CteateDrink() Drink
}

// A工厂生产 猪肉和牛奶
type AFactory struct {
}

type Pork struct {

}

func (p Pork) Eat()  {
	fmt.Println("eat pork")
}
func (a AFactory) CreateFood() Food {
	return Pork{}
}

type Milk struct {

}

func (m Milk) Drink()   {
	fmt.Println("drink milk")
}
func (a AFactory) CreateDrink() Drink {
	return Milk{}
}
// B工厂生产 羊肉和茶
type BFactory struct {
}

type Mutton struct {

}

func (m Mutton) Eat()  {
	fmt.Println("eat mutton")
}
func (b BFactory) CreateFood() Food {
	return Mutton{}
}

type Tea struct {

}

func (t Tea) Drink()   {
	fmt.Println("drink tea")
}

func (b BFactory) CreateDrink() Drink {
	return Tea{}
}

func main()  {
	// 套餐一
	fa := AFactory{}
	fa.CreateFood().Eat()
	fa.CreateDrink().Drink()
    // 套餐二
	fb := BFactory{}
	fb.CreateFood().Eat()
	fb.CreateDrink().Drink()
}